package com.xmut.dao;

import com.sirdc.modules.core.dao.GenericQuery;
import com.sirdc.modules.core.dao.LongDao;
import com.xmut.entity.Comment;
import com.xmut.filter.CommentFilter;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 *
 */
@Repository
public class CommentDao extends LongDao<Comment> {

    public List<Comment> query(CommentFilter filter) {
        GenericQuery query = createQuery("obj");
        if (filter.getTopicId() != null) {
            query.append(" and obj.topicId =:topicId ");
            query.setParam("topicId",filter.getTopicId());
        }

        return query.listResult(filter);
    }
}
